package com.huyanqi.front.rest.resource.impl;

import java.util.List;

import javax.annotation.Resource;

import com.huyanqi.core.RetdObj;
import com.huyanqi.entity.Comment;
import com.huyanqi.front.rest.RespCode;
import com.huyanqi.front.rest.resource.CommentListResource;
import com.huyanqi.front.rest.resp.CommentListResp;
import com.huyanqi.front.rest.service.CommentRestService;

public class CommentResourceImpl implements CommentListResource{

	private CommentRestService restService;
	
	@Resource(name="CommentRestService")
	public void setRestService(CommentRestService restService) {
		this.restService = restService;
	}
	public CommentRestService getRestService() {
		return restService;
	}
	
	@Override
	public CommentListResp findComments(Long cid) {
		CommentListResp slp = new CommentListResp();
		try{
			RetdObj<List<Comment>> retd = restService.findComments(cid);
			slp.setCode(RespCode.valueOf(retd.getCode()));
			slp.setData(retd.getRealObj());
		}catch (Exception e) {
			e.printStackTrace();
			slp.setCode(RespCode.EX_APP);
		}
		return slp;
	}
	
}
